<template>
  <div class="mod-config">
    <table-view ref="view"
                :searchAttrs="searchAttrs"
                :primaryKey="primaryKey"
                :listApiName="listApiName"
                :deleteApiName="deleteApiName"
                :saveAuthName="saveAuthName"
                :deleteAuthName="deleteAuthName"
                :showAttrs="showAttrs"
    >
    </table-view>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <trayinfo-add-or-update v-if="trayInfoVisible" ref="trayInfo"></trayinfo-add-or-update>
  </div>
</template>

<script>
import AddOrUpdate from './trayadd-add-or-update'
import TrayinfoAddOrUpdate from '@/views/modules/tray/trayinfo-add-or-update'
import tableView from '@/components/tableView'
import basicMixins from '@/utils/commonViewMixins'

export default {
  mixins: [basicMixins],
  data() {
    return {
      searchAttrs: {
        trayInfoId:{
          type: 'autoComplete',
          placeholder:'托盘编号',
          querySearchApiName: 'trayApi/getTrayInfoList'
        },
        dateTimeRange:{
          type: 'date',
          dateType: 'daterange',
          clearable: true
        }
      },
      primaryKey: 'id',
      listApiName: 'trayApi/listTrayAdd',
      deleteApiName: 'trayApi/deleteTrayAdd',
      trayInfoVisible: false,
      saveAuthName: 'tray:trayadd:save',
      deleteAuthName: 'tray:trayadd:delete',
      showAttrs: {
        trayOrderNo: {label: '订单编号'},
        trayInfoNo: {label: '托盘'},
        factoryName: {label: '工厂'},
        trayPrice: {label: '托盘价格'},
        trayNumber: {label: '入库数量'},
        dayTime: {label: '日期', type: 'date'},
        undefined: {label: '入库单', type: 'image'},
        createUser: {label: '创建人员'},
        createTime: {label: '创建时间', type: 'date'},
        updateUser: {label: '修改人员'},
        updateTime: {label: '修改时间', type: 'date'},
        status: {
          label: '状态',
          type: 'radio',
          items: [
            {value: 0, text: '禁用', tagType: 'danger'},
            {value: 1, text: '正常'}
          ]
        }
      }
    }
  },
  components: {
    TrayinfoAddOrUpdate,
    tableView,
    AddOrUpdate
  },
  methods: {
    openTrayInfoDialog(cb) {
      this.trayInfoVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.trayInfo)) {
          this.$refs.trayInfo.init(null, {status: 1}, cb)
        }
      })
    }
  }
}
</script>
